package 牛客;
/*24点*/
public class Game24Points {
    public static void main(String[] args) {
        int[] arr = new int[]{4,2,2,6};
        System.out.println(game24Points(arr));
    }

    private static boolean res = false;

    public static boolean game24Points(int[] arr){
        dg(arr, 1, arr[0]);
        return res;
    }

    private static void dg(int[] arr, int index, int temp){
        if (index > 3){ //因为下标从0开始 到3 一共4个
            if (temp == 24)
                res = true;
            return;
        }
        dg(arr, index+1, temp + arr[index]);
        dg(arr, index+1, temp - arr[index]);
        dg(arr, index+1, temp * arr[index]);
        dg(arr, index+1, temp / arr[index]);
    }
}
